Ravi Vishwakarma is a dedicated Software Developer with a passion for crafting efficient and innovative solutions. With a keen eye for detail and years of experience, he excels in developing robust software systems that meet client needs. His expertise spans across multiple programming languages and technologies, making him a valuable asset in any software development project.
ICSM
03-Sep-2025Problem:
You are given a string, and you want to know how many times each word appears in it.
Example:
Expected output (word frequency):
Step-by-Step Solution
1. Take the input string
2. Normalize the string
"This"and"this"as different words..,,, etc.).Now:
3. Split the string into words
Now:
4. Count word frequency
We can use:
collections.Counter(built-in shortcut)Method 1: Using Dictionary
Method 2: Using Counter
5. Display the result
Full Working Code
Output
Explanation Summary: